﻿using System;
using System.Windows.Forms;
using StockAnalyzer.Analyzer;
using StockAnalyzer.Core;
using StockAnalyzer.Factory;

namespace StockAnalyzer
{
    public partial class Mainform : Form
    {
        public Mainform()
        {
            InitializeComponent();
        }

        private StockCollection stocks = null;

        private void pricePositionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (stocks == null)
            {
                stocks = StockCollectionFactory.Make(DateTime.Parse("2009-01-01"), DateTime.Now);
            }
            var analyzer = new PriceAnalyzer(stocks);
            analyzer.Analyse();
        }

        private void moveAverageLineToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (stocks == null)
            {
                stocks = StockCollectionFactory.Make(DateTime.Parse("2009-01-01"), DateTime.Now);
            } 
            var alertor = new MovingAverageAlertor(stocks, 50);
            alertor.Build();
        }

        private void allOfAnalysisToolStripMenuItem_Click(object sender, EventArgs e)
        {
            pricePositionToolStripMenuItem_Click(sender, e);
            moveAverageLineToolStripMenuItem_Click(sender, e);
        }
    }
}